﻿using System.ComponentModel;
using System.Diagnostics;

namespace Neitzel.Irc.Client
{
    /// <summary>
    /// Configuration required for a IRC Client
    /// </summary>
    public class ClientConfig : INotifyPropertyChanged
    {
        #region Fields

        /// <summary>
        /// Tracesource for all log messages.
        /// </summary>
        private static readonly TraceSource Logger = new TraceSource(IrcConstants.TraceSourceName);

        #endregion 

        #region Lifetime

        /// <summary>
        /// Initializes a new instance of the ClientConfig class.
        /// </summary>
        public ClientConfig()
        {
            ServerConfig = new ServerConfig();
            ServerConfig.PropertyChanged += ServerConfigChanged;
        }

        private void ServerConfigChanged(object sender, PropertyChangedEventArgs e)
        {
            throw new System.NotImplementedException();
        }

        #endregion

        #region Properties

        /// <summary>
        /// Gets or sets information about the server.
        /// </summary>
        public ServerConfig ServerConfig { get; private set; }
        
        /// <summary>
        /// Gets or sets a value indicating whether Ping messages should be shown.
        /// </summary>
        public bool ShowPings { get; set; }

        #endregion

        #region INotifyPropertyChanged parts

        public event PropertyChangedEventHandler PropertyChanged;

        protected virtual void OnPropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            // prevent racing conditions
            var handler = PropertyChanged;

            // trigger event
            handler?.Invoke(sender, e);
        }

        #endregion
    }
}
